home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / drivers / mscdex / svd / svd.c < prev   
Encoding:
C/C++ Source or Header  |  1990-10-15  |  3.9 KB  |  158 lines

  1. /* SVD
  2. **
  3. ** DESCRIPTION
  4. **    SVD is a simple program to tell MSCDEX to change a
  5. **    drive's choice for the standard or coded character set 
  6. **    volume descriptor.
  7. **
  8. **    Note: parsing is very simplistic and doesn't deal with
  9. **    case that much at this point in time.
  10. **    Error checking needs work.
  11. **
  12. ** USAGE
  13. **    SVD [<drive letter>:] [svd | std]
  14. */
  15. /*
  16. ** HISTORY:
  17. **  This was left out of previous releases.
  18. **
  19. **  10/01/90 Resurrected -by- JohnYG (v1.0)
  20. **      Final (v1.0)
  21. */
  22.  
  23. /* FR_Svd() -
  24. **
  25. ** INPUTS
  26. **    AX = 0x150E
  27. **    BX = 0 - Get Sense, 1 - Set Sense
  28. **    CX = CDROM Drive letter (A=0, B=1...Z=25)
  29. **    DX = 0
  30. **
  31. ** DESCRIPTION
  32. **    Returns or sets the default sense MSCDEX has for a cdrom drive
  33. **    with regard to it's treatment of discs with both an PVD and a
  34. **    recognized SVD.
  35. **    
  36. ** OUTPUTS
  37. **    DH = 0 - Coded char sets not supported or coded char set not recognized
  38. **         1 - Standard Volume descriptor is default
  39. **         2 - Coded Char Set Volume descriptor is default
  40. **    DL = Recognized coded character set (only valid if DH = 2)
  41. **        1 - Shift Kanji
  42. */
  43.  
  44. #include <stdio.h>
  45. #include <ctype.h>
  46. #include <dos.h>
  47. #include <process.h>
  48. #include <string.h>
  49.  
  50.     /* Volume Descriptor Types */
  51. #define    VDT_BOOT        0
  52. #define    VDT_STANDARD        1
  53. #define    VDT_CODED        2
  54. #define    VDT_UNSPECIFIED        3
  55. #define    VDT_TERMINATOR        0xff
  56.  
  57. #define    SVD_ISO646        0
  58. #define    SVD_KANJI        1
  59.  
  60. extern void report_drives(void);
  61. extern void main(int, char *[]);
  62.  
  63. union REGS    inregs;
  64. union REGS    outregs;
  65. struct SREGS    segregs;
  66.  
  67. char        drvs[26];
  68. int        ndrv;
  69.  
  70. void report_drives()
  71.     {
  72.     char far    *d = drvs;
  73.     int        i;
  74.  
  75.     printf("There are %d CD-ROM drives\n", ndrv);
  76.  
  77.     inregs.x.ax = 0x150D;        /* Get drive letters        */
  78.     segregs.es  = FP_SEG(d);
  79.     inregs.x.bx = FP_OFF(d);    /* ES:BX points to buffer    */
  80.     int86x(0x2f, &inregs, &outregs, &segregs);
  81.  
  82.     i = 0;
  83.     while (i < ndrv) {
  84.         inregs.x.ax = 0x150E;    /* Get/Set Volume Descriptor Sense */
  85.         inregs.x.bx = 0x0000;    /* Get value */
  86.         inregs.x.cx = drvs[i];
  87.         inregs.x.dx = 0;
  88.         int86(0x2f, &inregs, &outregs);
  89.         if (outregs.x.cflag)
  90.             printf("error: Carry set!\n");
  91.         if (outregs.x.dx == 0)
  92.             printf("error: DX modified!\n");
  93.  
  94.         printf("    drive[%2d] = '%c' ", i, drvs[i] + 'A');
  95.         if (outregs.h.dh == VDT_STANDARD)
  96.             printf("STD\n");
  97.         else
  98.             printf("CODED %d %s\n", outregs.h.dl,
  99.                 outregs.h.dl == SVD_KANJI ? "KANJI" : "UNKNOWN");
  100.         i++;
  101.         }
  102.     }
  103.  
  104. void main(argc, argv)
  105. int    argc;
  106. char    *argv[];
  107.     {
  108.     char        drv;
  109.  
  110.         /* Check if MSCDEX installed */
  111.     inregs.x.ax = 0x1500;        /* Get num drives        */
  112.     inregs.x.bx = 0;        /* Set to zero            */
  113.     int86(0x2f, &inregs, &outregs);
  114.     ndrv = outregs.x.bx;        /* number of drives        */
  115.     if (ndrv == 0) {
  116.         printf("MSCDEX is not installed.\n");
  117.         exit(1);
  118.         }
  119.  
  120.     inregs.x.ax = 0x150C;    /* Get MSCDEX Version */
  121.     inregs.x.bx = 0x0000;    /* Default value */
  122.     int86(0x2f, &inregs, &outregs);
  123.         /* If it reports back 0, must be version 1.01 */
  124.     if (outregs.x.bx == 0)
  125.         outregs.x.bx = 0x0101;
  126.  
  127.     printf("MSCDEX version %d.%02d\n", outregs.h.bh, outregs.h.bl);
  128.  
  129.         /* This is just a guess...SVD will one day accompany
  130.         ** MSCDEX like tools accompany DOS but we can't quite
  131.         ** make it version specific yet.
  132.         */
  133.     if (outregs.h.bh > 3)
  134.         printf("Possibly incompatible SVD and MSCDEX versions\n");
  135.  
  136.     if (argc == 1) {
  137.         report_drives();
  138.         exit(0);
  139.         }
  140.             /* Get drive letter, make lower case */
  141.     drv = (char)((*argv[1]) | 0x20);
  142.     if (drv < 'a' || drv > 'z') {
  143.         printf("usage: SVD [<drive letter>:] [svd | std]\n");
  144.         exit(1);
  145.         }
  146.     drv -= 'a';            /* normalize drive letter to 0    */
  147.  
  148.     inregs.x.ax = 0x150E;    /* Get/Set Volume Descriptor Sense */
  149.     inregs.x.bx = 0x0001;    /* Set value */
  150.     inregs.x.cx = drv;
  151.     if (!strcmp("std", argv[2]) || !strcmp("STD", argv[2]))
  152.         inregs.x.dx = (VDT_STANDARD << 8) + SVD_ISO646;
  153.     else
  154.         inregs.x.dx = (VDT_CODED << 8) + SVD_KANJI;
  155.     int86(0x2f, &inregs, &outregs);
  156.     report_drives();
  157.     }
  158.